﻿using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UMLSynthesizer.CSharpAnalyzer.Elements;
using UMLSynthesizer.CSharpAnalyzer.Helpers;
using UMLSynthesizer.LangAnalyzer.Elements;
using UMLSynthesizer.LangAnalyzer.Expressions;
using UMLSynthesizer.LangAnalyzer.Statements;

namespace UMLSynthesizer.CSharpAnalyzer.Expressions
{
    class CSharpConditionalExpression : CSharpExpressionBase, IConditionalExpression
    {
        #region Fields

        CSharpExpressionHelper conditionHelper;
        CSharpExpressionHelper whenFalseHelper;
        CSharpExpressionHelper whenTrueHelper;

        #endregion

        #region Constructor

        public CSharpConditionalExpression(ConditionalExpressionSyntax expressionNode,
            IExpressionBase parentExpression,
            IStatementBase parentStatement)
            : base(expressionNode, parentExpression, parentStatement, ExpressionKinds.Conditional)
        {
            conditionHelper = new CSharpExpressionHelper(this, parentStatement, () => expressionNode.Condition);
            whenFalseHelper = new CSharpExpressionHelper(this, parentStatement, () => expressionNode.WhenFalse);
            whenTrueHelper = new CSharpExpressionHelper(this, parentStatement, () => expressionNode.WhenTrue);
        }

        #endregion

        #region Properties

        public IExpressionBase Condition { get { return conditionHelper.Expression; } }
        public IExpressionBase WhenFalse { get { return whenFalseHelper.Expression; } }
        public IExpressionBase WhenTrue { get { return whenTrueHelper.Expression; } }

        #endregion
    }
}
